package testconditionsAPI;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import conditionsAPI.ConditionDuplicatedException;
import conditionsAPI.ConditionsConfiguration;
import conditionsAPI.SimpleDomainCondition;

public class TestSimpleDomainCondition {

	private SimpleDomainCondition simpleCondition;
	private static final String CONDITION_NAME = "simple"; 
	
	@Before
	public void setUp() throws ConditionDuplicatedException{
		this.simpleCondition = new StubSimpleDomainCondition(CONDITION_NAME);
	}
	
	@After
	public void tearDown(){
		ConditionsConfiguration.reset();
	}
	
	@Test
	public void doNothingCheckSimpleConditionIsFalse(){
		assertFalse(this.simpleCondition.isTrue());
	}
	
	@Test
	public void processSimpleConditionCheckSimpleConditionIsTrue(){
		ConditionsConfiguration.processObject(this.simpleCondition);
		
		assertTrue(this.simpleCondition.isTrue());
	}
	
	@Test
	public void createTwoSimpleConditionWithSameNameAndThrowException(){
		@SuppressWarnings("unused")
		SimpleDomainCondition simpleConditionTwin = null;
		try {
			simpleConditionTwin = new StubSimpleDomainCondition(CONDITION_NAME);
			assertTrue(false);
		} catch (ConditionDuplicatedException e) {
			assertTrue(true);
		}
	}
}
